﻿using System;

namespace FDEE.Model
{

    public class MCCRebarRecord : RebarBase
    {
      
        /// <summary>
        /// MCC 型钢筋长度重量计算 - 直筋，可能存在两端搭接和锚固承台（其他构件）
        /// </summary>
        /// <param name="mBarMark">钢筋主编号，例如1</param>
        /// <param name="sBarMark">钢筋次编号，例如1.1，默认为0</param>
        /// <param name="cBarMark">钢筋字符编号，例如1a，默认为空</param>
        /// <param name="diameter">钢筋直径，按eDB选取</param>
        /// <param name="A">外边缘到外边缘长度</param>
        /// <param name="n">弯钩长度</param>
        /// <param name="r">折减圆弧长度</param>
        /// <param name="d">钢筋直径</param>
        /// <param name="quantity">数量</param>
        /// <param name="shapeConfig"></param>
        public MCCRebarRecord(int mBarMark, int sBarMark, string cBarMark, eDB diameter,
            int a, int b, int quantity, eShapeType shapeConfig)
            : base(mBarMark, sBarMark, cBarMark, diameter, quantity, shapeConfig)
        {
            if (a < 0 || b < 0 )
            {
                throw new Exception("MI筋结果异常请查询原因！");
            }
            A = a;
            B = b;
            this.r = RebarKnowledge.GerRadius(diameter);
            this.d = PublicEnumItems.GeteDBData(diameter.ToString());
            this.Formula = "L=2A+B-r-2d";
        }
       

        public override void SetLength()
        {
            Length = Math.Round((A*2 + B  - r - 2 * d)*0.001, 3, MidpointRounding.AwayFromZero);
            if (Length > 12 || Length < 0)
            {
                throw new Exception("MI长度计算异常，请查找原因！");
            }
        }
    }

}
